package com.llyb.config;

import com.llyb.listener.TestChatModelListener;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;
import java.util.List;

@Configuration
public class LLMConfig {

    @Bean(name = "qwen")
    public ChatModel chatModelQwen(){
        return OpenAiChatModel.builder().
                apiKey(System.getenv("aliQwen-api")).
                modelName("qwen-plus").
                baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1").
                logRequests(true). // 日志界别设置为debug才有效
                logResponses(true).// 日志界别设置为debug才有效
                listeners(List.of(new TestChatModelListener())).
                maxRetries(5).// 重试机制共计2次
                timeout(Duration.ofSeconds(2)).
                build();
    }



}